#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h> 

static const BUFFERSIZE = 256;
static const INIT = 1;
static const START = 2;
static const REQUESTUPDATE = 3;
static const UPDATE = 4;
static const HALLCALL = 5;

/*------------------------------------------
Message Protocols
INIT - ID(byte)
START - no other arguments
REQUESTUPDATE - no other arguments
UPDATE - ID(byte), STATE(byte), CURRENTFLOOR(byte), NEXTFLOOR(byte), DESTINATIONCOUNT(byte), DESTINATIONS(byte[])
HALLCALL - FLOORNUMBER(byte), DIRECTION(byte)
--------------------------------------------*/

char *init(char *buffer, int id){
	bzero(buffer,BUFFERSIZE);
	buffer[0] = (char) INIT;
	buffer[1] = (char) id;
	buffer[2] = '\n';
}

char *start(char *buffer){
	bzero(buffer,BUFFERSIZE);
	buffer[0] = START;
}
char *requestUpdate(char *buffer){
	bzero(buffer,BUFFERSIZE);
	buffer[0] = REQUESTUPDATE;
}

char *update(char *buffer, int id, int state, int currentFloor, int nextFloor, int destinationCount){
	bzero(buffer,BUFFERSIZE);	
	buffer[0] = (char) UPDATE;
	buffer[1] = (char) id;
	buffer[2] = (char) state;
	buffer[3] = (char) currentFloor;
	buffer[4] = (char) nextFloor;
	buffer[5] = (char) destinationCount;
	buffer[6] = '\n';
	
}

char *hallcall(char *buffer, int floor){
	bzero(buffer,BUFFERSIZE);	
	buffer[0] = HALLCALL;
	buffer[1] = floor;
	buffer[2] = direction;
}
